home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / Bowers Development / AppMaker 2.0b5 / Examples / PowerPlant / NeoAccess / CReminderEntry.cp < prev    next >
Encoding:
Text File  |  1995-10-05  |  4.5 KB  |  197 lines  |  [TEXT/MMCC]

  1. // CReminderEntry.cp - manage Reminder entries
  2. // Created 10/5/95 8:02 PM by AppMaker
  3.  
  4. #include "CReminderEntry.h"
  5.  
  6. #include "NeoTypes.h"
  7. #include CNeoDatabaseH
  8. #include CNeoMetaClassH
  9. #include CNeoStreamH
  10.  
  11. #include <String_Utils.h>
  12.  
  13. //----------
  14. CReminderEntry::CReminderEntry ()
  15. {
  16.     mDateField [0] = 0;
  17.     mTimeField [0] = 0;
  18.     mMessageField [0] = 0;
  19.     mAmPmChoice = 0;
  20.     mShowAlertCheck = false;
  21.     mPlaySoundCheck = false;
  22.     mShowIconCheck = false;
  23.     mSoundIndex = 0;
  24. }
  25.  
  26. //----------
  27. CReminderEntry::CReminderEntry    (CNeoDatabase    *inFile)
  28. {
  29.     fID = inFile->getUniqueID();
  30.             // ? redundant because CNeoPersist will do it automatically ?
  31.  
  32.     mDateField [0] = 0;
  33.     mTimeField [0] = 0;
  34.     mMessageField [0] = 0;
  35.     mAmPmChoice = 0;
  36.     mShowAlertCheck = false;
  37.     mPlaySoundCheck = false;
  38.     mShowIconCheck = false;
  39.     mSoundIndex = 0;
  40. }
  41.  
  42. //----------
  43. CReminderEntry::~CReminderEntry    ()
  44. {
  45. }
  46.  
  47. //----------
  48. // functions to access the data members
  49.  
  50. void    CReminderEntry::GetDateField    (StringPtr    text) const
  51. {
  52.     CopyPStr (mDateField, text);
  53. }
  54.  
  55. void    CReminderEntry::SetDateField    (ConstStr255Param    text)
  56. {
  57.     CopyPStr (text, mDateField);
  58. }
  59.  
  60. void    CReminderEntry::GetTimeField    (StringPtr    text) const
  61. {
  62.     CopyPStr (mTimeField, text);
  63. }
  64.  
  65. void    CReminderEntry::SetTimeField    (ConstStr255Param    text)
  66. {
  67.     CopyPStr (text, mTimeField);
  68. }
  69.  
  70. void    CReminderEntry::GetMessageField    (StringPtr    text) const
  71. {
  72.     CopyPStr (mMessageField, text);
  73. }
  74.  
  75. void    CReminderEntry::SetMessageField    (ConstStr255Param    text)
  76. {
  77.     CopyPStr (text, mMessageField);
  78. }
  79.  
  80. void    CReminderEntry::SetAmPmChoice    (long        state)
  81. {
  82.     mAmPmChoice = state;
  83. }
  84.  
  85. void    CReminderEntry::SetShowAlertCheck    (Boolean        state)
  86. {
  87.     mShowAlertCheck = state;
  88. }
  89.  
  90. void    CReminderEntry::SetPlaySoundCheck    (Boolean        state)
  91. {
  92.     mPlaySoundCheck = state;
  93. }
  94.  
  95. void    CReminderEntry::SetShowIconCheck    (Boolean        state)
  96. {
  97.     mShowIconCheck = state;
  98. }
  99.  
  100. void    CReminderEntry::SetSoundIndex    (short        state)
  101. {
  102.     mSoundIndex = state;
  103. }
  104.  
  105. //----------
  106. CNeoMetaClass*        CReminderEntry::GetMetaClass    (void)
  107. {
  108.     return CNeoMetaClass::GetMetaClass (kReminderEntryID);
  109. }
  110.  
  111. //----------
  112. void    CReminderEntry::AddMetaClass    (void)
  113. {
  114.     CNeoMetaClass    *meta;
  115.  
  116.     meta = CReminderEntry::GetMetaClass ();
  117.     if (meta == nil) {
  118.         new CNeoMetaClass (kReminderEntryID, kNeoPersistID,
  119.                             "\pCReminderEntry", CReminderEntry::New);
  120.     }
  121. }
  122.  
  123. //----------
  124. CNeoPersist*        CReminderEntry::New (void)
  125. {
  126.     return new CReminderEntry;
  127. }
  128.  
  129. //----------
  130. #pragma segment NeoSearch
  131. CReminderEntry*        CReminderEntry::FindByID    (CNeoDatabase    *aFile,
  132.                                             const NeoID            aID,
  133.                                             const Boolean        aDeeply,
  134.                                                   NeoTestFunc1    aFunc,
  135.                                                   void*            aParam,
  136.                                             const NeoLockType    aLock)
  137. {
  138.     return (CReminderEntry *)CNeoPersist::FindByID (aFile, kReminderEntryID,
  139.                                                     aID, aDeeply,
  140.                                                     aFunc, aParam, aLock);
  141. }
  142.  
  143. //----------
  144. // This method returns the amount of file space the object occupies in the file.
  145. // It differs from the getLength() in that getLength returns the size of the
  146. // object in memory.
  147. #pragma segment NeoInfo
  148. long    CReminderEntry::getFileLength    (void) const
  149. {
  150. const long kReminderEntryDataLength =
  151.                 (sizeof(mDateField)
  152.                 + sizeof(mTimeField)
  153.                 + sizeof(mMessageField)
  154.                 + sizeof(mAmPmChoice)
  155.                 + sizeof(mShowAlertCheck)
  156.                 + sizeof(mPlaySoundCheck)
  157.                 + sizeof(mShowIconCheck)
  158.                 + sizeof(mSoundIndex));
  159. const long kReminderEntryFileLength = (kNeoPersistFileLength + kReminderEntryDataLength);
  160.  
  161.     return kReminderEntryFileLength;
  162. }
  163.  
  164. //----------
  165. #pragma segment NeoRead
  166. void    CReminderEntry::readObject        (CNeoStream        *aStream,
  167.                                          const NeoTag    aTag)
  168. {
  169.     inherited::readObject(aStream, aTag);
  170.  
  171.     aStream->readString (mDateField, sizeof(mDateField), aTag);
  172.     aStream->readString (mTimeField, sizeof(mTimeField), aTag);
  173.     aStream->readString (mMessageField, sizeof(mMessageField), aTag);
  174.     mAmPmChoice = aStream->readLong (aTag);
  175.     mShowAlertCheck = aStream->readBoolean (aTag);
  176.     mPlaySoundCheck = aStream->readBoolean (aTag);
  177.     mShowIconCheck = aStream->readBoolean (aTag);
  178.     mSoundIndex = aStream->readShort (aTag);
  179. }
  180.  
  181. //----------
  182. #pragma segment NeoWrite
  183. void    CReminderEntry::writeObject        (CNeoStream        *aStream,
  184.                                          const NeoTag    aTag)
  185. {
  186.     inherited::writeObject(aStream, aTag);
  187.  
  188.     aStream->writeString (mDateField, sizeof(mDateField), aTag);
  189.     aStream->writeString (mTimeField, sizeof(mTimeField), aTag);
  190.     aStream->writeString (mMessageField, sizeof(mMessageField), aTag);
  191.     aStream->writeLong (mAmPmChoice, aTag);
  192.     aStream->writeBoolean (mShowAlertCheck, aTag);
  193.     aStream->writeBoolean (mPlaySoundCheck, aTag);
  194.     aStream->writeBoolean (mShowIconCheck, aTag);
  195.     aStream->writeShort (mSoundIndex, aTag);
  196. }
  197.